﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YLServerInterface.YLAdminService;
using YLPublicService;

namespace YLServerInterface.FunctionalClass
{
    public class ServerInterface
    {
        public AdminServiceClient client { get; private set; }
        public Guid loginGuid { get; private set; }
        public ServerInterface()
        {
            client = new AdminServiceClient();
        }
        public bool Login(User user)
        {
            loginGuid = client.Login(user.LoginName,user.PassWord);
            return loginGuid == Guid.Empty ? false : true;
        }
        public User[] GetUsers(Guid guid)
        {
            return client.GetUsers(guid);
        }
        public IEnumerable<WorkItem> GetWorkItems(User user, Guid guid)
        {
            CodeContract.Requires(guid != Guid.Empty, "Guid must not 0");
            return client.GetWorkItems(user.LoginName, guid);
        }
        public bool AddUser(string loginName, string pwd, string userName, string memo, Guid guid)
        {
            return client.AddUser(loginName, pwd, userName, memo, guid);
        }
    }
}
